package com.cmy.dao;

import com.cmy.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

public class UserMapperImpl implements UserMapper{
    private SqlSessionTemplate sqlSession;

    public void setSqlSession(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }

    public List<User> getUsers() {
        return sqlSession.getMapper(UserMapper.class).getUsers();
    }

    public int addUser(User user) {

        return sqlSession.getMapper(UserMapper.class).addUser(user);

    }

    public int deleteUser(int id) {
        return sqlSession.getMapper(UserMapper.class).deleteUser(id);
    }

    public void txTest(){
        User user = new User(4, "new", "445644");
        this.addUser(user);
        this.deleteUser(3);
    }
}

    